package com.changli02.selfdefine.exer2;

import org.junit.Test;

import java.util.Arrays;

public class Exer2 {
    public static <E> void method1 (E[] e,int a,int b){
        E temp = e[a];
        e[a] = e[b];
        e[b] = temp;
    }
    @Test
    public void test1(){
        String [] s = new String [] {"a","b","c"};
        method1(s,1,2);
        System.out.println(Arrays.toString(s));

    }
    public static <E> void method2 (E[] e){
        for (int i=0,j=e.length-1;i<j;i++,j--) {
            E temp = e[i];
            e[i]=e[j];
            e[j]=temp;
        }
    }
    @Test
    public void test2(){
        Integer [] in = new Integer [] {1,2,3,4,5,6,7,8,9};
        method2(in);
        System.out.println(Arrays.toString(in));


    }
}
